/**
 * 所有的ajax服务调用
 */

AdminService = {
	'Login' : function(user_id, pwd) {
		// 登陆功能
		var lst_sku = new Array();
		lst_sku.push('user_id=' + user_id);
		lst_sku.push('password=' + pwd);
		var str_param = lst_sku.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/admin/login',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
				
			},
			error : function(e) {
				result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
			}
		});
		return result;
	},
	'Logout' : function(user_id, pwd) {
		// 登陆功能
		var lst_param = new Array();
		lst_param.push('user_id=' + user_id);
		var str_param = lst_param.join('&');
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/admin/logout',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
        	  error : function(e, err_name, err_text) {
        		  result = {};
        		  result.IsSuccess = 0;
        		  result.ErrorMsg = err_text;
        		  result.ErrorCode = 4;
        	  }
		});
		return result;
	},
};


PromoterService = {
	'SearchPromoterList': function(promoter_id, cellphone, promoter_type, promoter_name, page_index, page_size){
		// 申请提现
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' + promoter_id);
		lst_sku.push('cellphone=' 	+ cellphone);
		lst_sku.push('promoter_type=' + promoter_type);
		lst_sku.push('promoter_name=' + promoter_name);
		lst_sku.push('page_index=' 	+ page_index);
		lst_sku.push('page_size=' 	+ page_size);
		var str_param = lst_sku.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/searchPromoterList',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'SearchAmountList': function( promoter_id, page_index, page_size){
		// 申请提现
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' + promoter_id);
		lst_sku.push('page_index=' 	+ page_index);
		lst_sku.push('page_size=' 	+ page_size);
		var str_param = lst_sku.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/searchAmountList',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'SearchWithdrawAmountList': function( promoter_id, page_index, page_size){
		// 申请提现
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' + promoter_id);
		lst_sku.push('page_index=' 	+ page_index);
		lst_sku.push('page_size=' 	+ page_size);
		var str_param = lst_sku.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/searchWithdrawAmountList',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'SearchWithdrawList': function(promoter_id, promoter_name, page_index, page_size){
		// 申请提现
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' + promoter_id);
		lst_sku.push('promoter_name=' + promoter_name);
		lst_sku.push('page_index=' 	+ page_index);
		lst_sku.push('page_size=' 	+ page_size);
		var str_param = lst_sku.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/searchWithdrawList',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'UpdateAmount': function(promoter_id, amount, amount_type, remark){
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' 	+ promoter_id);
		lst_sku.push('amount=' 		+ amount);
		lst_sku.push('amount_type=' 	+ amount_type);
		lst_sku.push('remark=' 	+ remark);
		var str_param = lst_sku.join('&');

		
		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/updateAmount',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'UpdatePromoterStatus': function(promoter_id,status,reject_reason){
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' 	+ promoter_id);
		lst_sku.push('reject_reason=' 	+ reject_reason);
		lst_sku.push('status=' 		+ status);
		var str_param = lst_sku.join('&');
		var result = null;
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/updatePromoterStatus',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
	'ResetPwd': function(promoter_id){
		// 申请提现
		var lst_sku = new Array();
		lst_sku.push('promoter_id=' 	+ promoter_id);
		var str_param = lst_sku.join('&');

		var result = null;
		
		$.ajax({
			type : 'post',
			url : '/AjaxService/center/promoter/resetPwd',
			data : str_param,
			dataType : 'json',
			async : false,
			success : function(data) {
				result = data;
			},
      	  error : function(e, err_name, err_text) {
    		  result = {};
    		  result.IsSuccess = 0;
    		  result.ErrorMsg = err_text;
    		  result.ErrorCode = 4;
    	  }
		});
		return result;
	},
};


OrderService = {
		'SearchOrderList': function(promoter_id, promoter_name, order_id, order_status, payment_status, begin_order_date, end_order_date, page_index, page_size){
			var lst_sku = new Array();
			lst_sku.push('promoter_id=' 		+ promoter_id);
			lst_sku.push('promoter_name='		+ promoter_name);
			lst_sku.push('order_id=' 			+ order_id);
			lst_sku.push('order_status=' 		+ order_status);
			lst_sku.push('payment_status=' 	+ payment_status);
			lst_sku.push('begin_order_date='	+ begin_order_date);
			lst_sku.push('end_order_date=' 	+ end_order_date);
			lst_sku.push('page_index=' 		+ page_index);
			lst_sku.push('page_size=' 		+ page_size);
			var str_param = lst_sku.join('&');

			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/searchOrderList',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		'CancelOrder': function(order_id){
			var lst_sku = new Array();
			lst_sku.push('order_id='+ order_id);
			var str_param = lst_sku.join('&');

			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/order/cancelOrder',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
};


SkuService = {
		'SearchSkuList': function(style_sn, style_name,is_buy_fz, page_index, page_size){
			var lst_sku = new Array();
			lst_sku.push('style_sn=' + style_sn);
			lst_sku.push('style_name=' 	+ style_name);
			lst_sku.push('is_buy_fz=' 	+ is_buy_fz);
			lst_sku.push('page_index=' 	+ page_index);
			lst_sku.push('page_size=' 	+ page_size);
			var str_param = lst_sku.join('&');

			var result = null;
			
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/sku/searchSkuList',
				data : str_param,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	      	  error : function(e, err_name, err_text) {
	    		  result = {};
	    		  result.IsSuccess = 0;
	    		  result.ErrorMsg = err_text;
	    		  result.ErrorCode = 4;
	    	  }
			});
			return result;
		},
		
		
		'querySkuByPara': function( sku_sn, sku_name, style_name,product_name, sku_channel ){
			var lst_style = new Array();
			
			lst_style.push('sku_sn=' 	+ sku_sn);
			lst_style.push('sku_name=' 	+ sku_name);
			lst_style.push('style_name=' 	+ style_name);
			lst_style.push('product_name=' 	+ product_name);				
			lst_style.push('sku_channel=' 	+ sku_channel);
			
			
			var str_style = lst_style.join('&');
			var result = null;
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/sku/querySkuByPara',
				data : str_style,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	     	  error : function(e, err_name, err_text) {
	   		  result = {};
	   		  result.IsSuccess = 0;
	   		  result.ErrorMsg = err_text;
	   		  result.ErrorCode = 4;
	   	  }
			});
			return result;
		},
		
		
		'GetProductID':function(){
			
			var result = null;
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/sku/getProductId',
				data : null,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	     	  error : function(e, err_name, err_text) {
	   		  result = {};
	   		  result.IsSuccess = 0;
	   		  result.ErrorMsg = err_text;
	   		  result.ErrorCode = 4;
	   	  }
			});
			return result;
		},
		
	    'GetStyleID':function(){
	    	var result = null;
			$.ajax({
				type : 'post',
				url : '/AjaxService/center/sku/getStyleId',
				data : null,
				dataType : 'json',
				async : false,
				success : function(data) {
					result = data;
				},
	     	  error : function(e, err_name, err_text) {
	   		  result = {};
	   		  result.IsSuccess = 0;
	   		  result.ErrorMsg = err_text;
	   		  result.ErrorCode = 4;
	   	  }
			});
			return result;
		},
		 'GetSkuID':function(){
		    	var result = null;
				$.ajax({
					type : 'post',
					url : '/AjaxService/center/sku/getSkuId',
					data : null,
					dataType : 'json',
					async : false,
					success : function(data) {
						result = data;
					},
		     	  error : function(e, err_name, err_text) {
		   		  result = {};
		   		  result.IsSuccess = 0;
		   		  result.ErrorMsg = err_text;
		   		  result.ErrorCode = 4;
		   	  }
				});
				return result;
			},
	};
	StyleService = {
			
			'AddStyle': function( style_sn,  style_name, style_brief ,
					sku_channel, sku_channel_name, sale_date, market_price , shop_price,
					sale_min_price , sale_max_price , sku_stock , is_real ,
					status ){
				var lst_style = new Array();
				lst_style.push('style_sn=' 	+ style_sn);
				lst_style.push('style_name=' 	+ style_name);
				lst_style.push('style_brief=' 	+ style_brief);
				lst_style.push('sku_channel=' 	+ sku_channel);
				lst_style.push('sku_channel_name=' 	+ sku_channel_name);
				lst_style.push('sale_date=' 	+ sale_date);
				lst_style.push('market_price=' 	+ market_price);
				lst_style.push('shop_price=' 	+ shop_price);
				lst_style.push('sale_min_price=' 	+ sale_min_price);
				lst_style.push('sale_max_price=' 	+ sale_max_price);
				lst_style.push('sku_stock=' 	+ sku_stock);
				lst_style.push('is_real=' 	+ is_real);
				lst_style.push('status=' 	+ status);
				
				var str_style = lst_style.join('&');
				var result = null;
				$.ajax({
					type : 'post',
					url : '/AjaxService/center/style/addStyle',
					data : str_style,
					dataType : 'json',
					async : false,
					success : function(data) {
						result = data;
					},
		     	  error : function(e, err_name, err_text) {
		   		  result = {};
		   		  result.IsSuccess = 0;
		   		  result.ErrorMsg = err_text;
		   		  result.ErrorCode = 4;
		   	  }
				});
				return result;
			},
			
			

			'UpdateStyle': function( style_id ,style_sn,  style_name, style_brief ,
					sku_channel, sku_channel_name, sale_date, market_price , shop_price,
					sale_min_price , sale_max_price , sku_stock , is_real ,
					status ){
				var lst_style = new Array();
				lst_style.push('style_id=' +style_id);
				lst_style.push('style_sn=' 	+ style_sn);
				lst_style.push('style_name=' 	+ style_name);
				lst_style.push('style_brief=' 	+ style_brief);
				lst_style.push('sku_channel=' 	+ sku_channel);
				lst_style.push('sku_channel_name=' 	+ sku_channel_name);
				lst_style.push('sale_date=' 	+ sale_date);
				lst_style.push('market_price=' 	+ market_price);
				lst_style.push('shop_price=' 	+ shop_price);
				lst_style.push('sale_min_price=' 	+ sale_min_price);
				lst_style.push('sale_max_price=' 	+ sale_max_price);
				lst_style.push('sku_stock=' 	+ sku_stock);
				lst_style.push('is_real=' 	+ is_real);
				lst_style.push('status=' 	+ status);
				
				var str_style = lst_style.join('&');
				var result = null;
				$.ajax({
					type : 'post',
					url : '/AjaxService/center/style/updateStyle',
					data : str_style,
					dataType : 'json',
					async : false,
					success : function(data) {
						result = data;
					},
		     	  error : function(e, err_name, err_text) {
		   		  result = {};
		   		  result.IsSuccess = 0;
		   		  result.ErrorMsg = err_text;
		   		  result.ErrorCode = 4;
		   	  }
				});
				return result;
			},
			
			'queryStyleByPara': function( style_sn, style_name,sku_channel ){
				var lst_style = new Array();
				
				lst_style.push('style_sn=' 	+ style_sn);
				lst_style.push('style_name=' 	+ style_name);				
				lst_style.push('sku_channel=' 	+ sku_channel);
				
				
				var str_style = lst_style.join('&');
				var result = null;
				$.ajax({
					type : 'post',
					url : '/AjaxService/center/style/queryStyleByPara',
					data : str_style,
					dataType : 'json',
					async : false,
					success : function(data) {
						result = data;
					},
		     	  error : function(e, err_name, err_text) {
		   		  result = {};
		   		  result.IsSuccess = 0;
		   		  result.ErrorMsg = err_text;
		   		  result.ErrorCode = 4;
		   	  }
				});
				return result;
			},
			
		};

